<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>注册页面</title>
		<script type="text/javascript" src="vue.js"></script>
		<script type="text/javascript" src="axios.min.js"></script>
		<script type="text/javascript" src="const.js"></script>
	</head>
	<body>
		<div id="app">
			<input v-model="username"/><br />
			<input v-model="password"/><br />
			<input v-model="confirmPassword" />
			<button v-on:click="register">注册</button>
		</div>
	</body>
	<script type="text/javascript">
		/* 创建配置对象 */
		var config={
			el:"#app",
			data:{
				username:"请输入用户名",
				password:"请输入密码",
				confirmPassword:"请确认密码"
			},
			methods:{
				register:function(){
					debugger;
					//window.alert("run");
					//判断密码是否一致
					if(this.password!=this.confirmPassword){
						window.alert("密码不一致！");
						return;
					}
					//联网
					//1、设置联网服务器地址
					var serverUrl=serverHost+"/user/register?username="+this.username+"&password="+this.password;
					//2、发请求
					axios.get(serverUrl)
					.then(function(response){
						//接收服务器返回的结果
						debugger;
						//从response中获取结果
						var result=response.data;
						window.alert(result);//在console查看错误信息
					})
					.catch();
					//3、接收服务器返回的结果
				}
			}
		}
		var vue=new Vue(config);
	</script>
</html>
